Skip to content

feat(sc-dbuser) add policy for sc-dbuser #3

Merged
merged 4 commits into from
Jun 10, 2026
Merged

feat(sc-dbuser) add policy for sc-dbuser #3

merged 4 commits into from
Jun 10, 2026

Conversation

morga471
Copy link
Contributor

@morga471 morga471 commented Mar 16, 2026

This creates the policy object for sc-dbuser.
this will be used to create sso PS following normal patterns.
this is only to resolve the postgres dbuser use-case, we will address oracle specific concerns at a later time.

@morga471 morga471 requested a review from badra001 March 16, 2026 21:10
Copy link
Contributor

@badra001 badra001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to be sc-dbuser
See other changes/comments

@morga471 morga471 changed the title feat(sc-db-user) add policy for sc-db-user feat(sc-dbuser) add policy for sc-dbuser Mar 20, 2026
@morga471 morga471 requested a review from badra001 March 20, 2026 17:29
@morga471
Copy link
Contributor Author

changes applied from feedback

@badra001
Copy link
Contributor

badra001 commented Mar 24, 2026

I'm not seeing anything here which describes how one would use this with specific secrets. I do not believe we have defined (at an ent level) how to leverage secretsmanager with JBIDs. We need to define that. The two options shown in there should be more clearly scoped. For example, the jbid should be in a tag which we define (not Name). rds_username is what we should be using (so we'll add this doc somewhere), with a condition like

    condition {
      test     = "StringEquals"
      variable = "secretsmanager:ResourceTag/rds_username"
      values   = ["$${aws:PrincipalTag/jbid}"]
    }

@morga471
Copy link
Contributor Author

I'm not seeing anything here which describes how one would use this with specific secrets. I do not believe we have defined (at an ent level) how to leverage secretsmanager with JBIDs. We need to define that. The two options shown in there should be more clearly scoped. For example, the jbid should be in a tag which we define (not Name). rds_username is what we should be using (so we'll add this doc somewhere), with a condition like

    condition {
      test     = "StringEquals"
      variable = "secretsmanager:ResourceTag/rds_username"
      values   = ["$${aws:PrincipalTag/jbid}"]
    }

So this condition is saying that the secret should have a tag on it that is the rds_username tag, and the values in that tag should include the jbid of the caller, which is validated by the caller (aws:principalTag/jbid) having their jbid on their session? I don't think we currently add the jbid of a user to the IAM role or user that makes this call. So this wont work either. I included them per our conversation but this approach is definitely not ready for prime time.

I am getting pressure to move this forward as it's part of a POAM. Since we know this wont work as is, I will remove the conditions until we are ready to implement something for secrets management.

@morga471 morga471 requested a review from badra001 March 24, 2026 21:47
@morga471
Copy link
Contributor Author

morga471 commented Apr 7, 2026

Follow up conversation with Mike Jones and Kalyana. Clarified effort is only for postgres and oracle concerns are out of scope. pulled out statements that were not relevant for postgres.

@badra001
Copy link
Contributor

badra001 commented Apr 8, 2026

Follow up conversation with Mike Jones and Kalyana. Clarified effort is only for postgres and oracle concerns are out of scope. pulled out statements that were not relevant for postgres.

Can you include the references to ADSD DBA documentation for how access to Postgres using IAM is to be setup and used, from both the command linux (say a linux host with a linux cli and python connection) as well as a DB tool such as DBeaver?

Also, this policy allows connecting to every database in the account to which this role/policy is applied. How are we restricting access by DB to only the approrpriate SSO users?

@morga471
Copy link
Contributor Author

morga471 commented Apr 8, 2026

Follow up conversation with Mike Jones and Kalyana. Clarified effort is only for postgres and oracle concerns are out of scope. pulled out statements that were not relevant for postgres.

Can you include the references to ADSD DBA documentation for how access to Postgres using IAM is to be setup and used, from both the command linux (say a linux host with a linux cli and python connection) as well as a DB tool such as DBeaver?

Also, this policy allows connecting to every database in the account to which this role/policy is applied. How are we restricting access by DB to only the approrpriate SSO users?

Yeah, this grants access to every DB because it's a two sided operation. In order for rds-db:connect to function, the user needs to be enabled for iam login inside the db. This permission grants nothing if the db isn't configured to enable it.

ADSD doc includes connection instructions in a docx. I can attach that here if desired.

@badra001
Copy link
Contributor

badra001 commented Apr 8, 2026

Follow up conversation with Mike Jones and Kalyana. Clarified effort is only for postgres and oracle concerns are out of scope. pulled out statements that were not relevant for postgres.

Can you include the references to ADSD DBA documentation for how access to Postgres using IAM is to be setup and used, from both the command linux (say a linux host with a linux cli and python connection) as well as a DB tool such as DBeaver?
Also, this policy allows connecting to every database in the account to which this role/policy is applied. How are we restricting access by DB to only the approrpriate SSO users?

Yeah, this grants access to every DB because it's a two sided operation. In order for rds-db:connect to function, the user needs to be enabled for iam login inside the db. This permission grants nothing if the db isn't configured to enable it.

ADSD doc includes connection instructions in a docx. I can attach that here if desired.

yes please

@morga471 morga471 self-assigned this May 5, 2026
@tarti001
Copy link

Security Impact Analysis:
Describes a functionality change for a mandatory OKTA MFA deployment. No noted specifically security related issues affecting access control, training, auditing, secure configuration, information assurance, contingency planning, maintenance, physical access control, privacy, secure communications, or system integrity. Change management and testing process must validate accuracy of transaction / functionality changes.

@badra001
Copy link
Contributor

badra001 commented Jun 3, 2026

  1. update readme
  2. include text of cli command, cli output, no image needed
  3. add condition for PrinicipalTag/UserName
  4. for the statements use format() and include proper partition
  5. check on sdk tools which can use an aws profile with the aws SDK
  6. test out afterwards with 2 users, make sure user can see their DB (and verify its their connection), along with testing against a differnet user than signed in, and finally with a non-SSO thing (local user)

rename to sc-dbuser

update from comments

fix syntax for passthrough var

remove jbid stuff

reduce to postgres usecase requirements only

update changelog

fix name

Create README.md

adding RDS MFA converted from .docx

Update README.md with RDS MFA steps

Create temp file in folder

Add files via upload
@morga471 morga471 requested a review from badra001 June 10, 2026 19:05

Choose one path depending on your deployment type.

### RDS PostgreSQL instance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like terraform null resource example of making this change via Terraform (will not hold up merge for it though)

}
```

### Aurora PostgreSQL cluster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like terraform null resource example of making this change via Terraform (will not hold up merge for it though)

Comment on lines +98 to +109
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["rds-db:connect"],
"Resource": ["arn:aws:rds-db:us-east-1:123456789012:dbuser:cluster-ABCDEFGHIJKL01234/mydbuser"]
}
]
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this value come from? I'd expect some details on how to construct the specific ARN here. We should also have a terraform data resource for the policy statement and not hardcode stuff. Also, we won't be able to do this with an SSO role.

Comment on lines +83 to +94
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["rds-db:connect"],
"Resource": ["arn:aws:rds-db:us-east-1:123456789012:dbuser:db-ABCDEFGHIJKL01234/mydbuser"]
}
]
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this value come from? I'd expect some details on how to construct the specific ARN here. We should also have a terraform data resource for the policy statement and not hardcode stuff. Also, we won't be able to do this with an SSO role.

}
```

## 2. Create or update IAM policy for connect permission
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is dbuser? Is it the JBID? The email address?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the policy, it is the email address (all lowercase). See https://github.e.it.census.gov/terraform-modules/aws-sso/pull/3/files#diff-fb90d613136f0d47a7d3fd49d287d6fcb5a7dc7005dd0704ffc05ee272f5cef8R27-R37.

Please indicate that it's an email address.

```

Token notes:
- Token lifetime is about 15 minutes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this adjustable?

Copy link
Contributor

@badra001 badra001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved so you can test, but please address the comments in a later revision.

@badra001
Copy link
Contributor

Be sure to address the comments post-testing.

@badra001 badra001 merged commit 638054f into master Jun 10, 2026
@morga471 morga471 deleted the sc-db-user branch June 10, 2026 19:26
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants